module.exports = {
    pageget: (req, rest) => {
        var rows = (req.query.row || req.query.hasOwnProperty('row') || isNaN(req.query.row) == false) ? (Number(req.query.row) <= 0 ? 1 : Number(req.query.row)) : '10'

        var row = ' limit ' + rows

        var total = rest && rest[0] && rest[0]['count(*)'] || 0

        var maxpagesize = (((
            Number(req.query.pagesize)
        ) - 1 <= 0 ? 0 : (
            Number(req.query.pagesize)
        ) - 1))
            > (total % rows == 0 ? total / rows : (total - (total % rows)) / rows + 1) - 1 ?
            (total % rows == 0 ? total / rows : (total - (total % rows)) / rows + 1) - 1 :
            (((
                Number(req.query.pagesize)
            ) - 1 < 0 ? 0 : (
                Number(req.query.pagesize)
            ) - 1))

        var pagesize = ((req.query.pagesize || req.query.hasOwnProperty('pagesize') || isNaN(req.query.pagesize) == false) ? (' offset ' + maxpagesize * ((req.query.row || req.query.hasOwnProperty('row') || isNaN(req.query.row) == false) ? req.query.row : 10)) : ' offset 0')

        return {
            rows, row, total, maxpagesize, pagesize
        }
    }
}